package view;

import javax.swing.table.AbstractTableModel;

/**
 * @author Adam Scarr
 * @since r1
 */
public class FlightTableUI extends AbstractTableModel {
    private final static String[] columnNames = {"From", "To", "Cost", "Seats", "Date"};
    private final static String[][] rowData = {
            {"Townsville", "Cairns", "$40", "150", "13/04/2009"},
            {"Townsville", "Cairns", "$44", "50", "03/04/2009"},
            {"Townsville", "Cairns", "$46", "250", "09/04/2009"},
            {"Townsville", "Cairns", "$41", "50", "14/04/2009"},
            {"Townsville", "Cairns", "$43", "125", "16/04/2009"},
            {"Townsville", "Cairns", "$50", "140", "02/04/2009"},
            {"Townsville", "Cairns", "$51", "130", "05/04/2009"},
            {"Townsville", "Cairns", "$45", "10", "10/04/2009"},
            {"Townsville", "Cairns", "$55", "40", "06/04/2009"},
            {"Townsville", "Cairns", "$60", "90", "15/04/2009"}
    };

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public int getRowCount() { return rowData.length; }

    public int getColumnCount() { return columnNames.length; }

    public Object getValueAt(int row, int col) {
        return rowData[row][col];
    }

    public boolean isCellEditable(int row, int col) {
        return false;
    }
    
    public void setValueAt(String value, int row, int col) {
        rowData[row][col] = value;
        fireTableCellUpdated(row, col);
    }

}
